home *** CD-ROM | disk | FTP | other *** search
/ Chip: Internet / Chip Internet.iso / viewer / emtex.ins / dvineclq / dviproc.zoo / pctex / dvialw.ps < prev    next >
Text File  |  1987-09-18  |  9KB  |  297 lines

  1. % <BEEBE.TEX.DVI>DVIALW.PS.17, 18-Sep-87 17:48:04, Edit by BEEBE
  2. % Add test for note paper and if unknown, use letter paper instead.
  3. % Non-Apple PostScript implementations do not know about note paper
  4. % but its use on the Apple LaserWriter gains 92K of virtual memory
  5. % <BEEBE.TEX.DVI>DVIALW.PS.16, 18-Sep-87 15:50:52, Edit by BEEBE
  6. % Modify coordinate computations to remove round-off errors
  7. % in landscape mode, and correct landscape page origin
  8. % <BEEBE.TEX.DVI>DVIALW.PS.14, 22-Jun-87 09:55:05, Edit by BEEBE
  9. % Add missing "0 900 translate Mtrx currentmatrix pop" to /LEGAL
  10. % <BEEBE.TEX.DVI>DVIALW.PS.13,  7-Jan-87 17:38:51, Edit by BEEBE
  11. % Add translate command to BOP so that (0,0) really corresponds to
  12. % the top left physical page corner.  The standard LaTeX file 
  13. % TESTPAGE.TEX can be used for this calibration; it might be sensitive
  14. % to the particular printer used.    
  15. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.12, 10-Dec-86 17:24:50, Edit by BEEBE
  16. % Fix off-by-one error in definition of /B; to draw a box N pixels
  17. % wide, microscopic examination of output shows that the box width
  18. % must be N-1, not N, pixels; the boundary counts in the filling.                
  19. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.9, 28-Nov-86 19:00:52, Edit by BEEBE
  20. % Change definition of EOP to use #copies and showpage
  21. % instead of {copypage} repeat erasepage
  22. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.7, 16-Oct-86 13:09:36, Edit by BEEBE
  23. % Following Macintosh LaserWriter md dictionary, change most
  24. % def's to bdf's (bind def); this is claimed to speed up
  25. % operator access
  26. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.5, 16-Oct-86 12:01:12, Edit by BEEBE
  27. % Change CTL-L to caret-L in comment
  28. % <BEEBE.TEX.DVI.NEW>DVIALW.PS.3, 13-Jun-86 10:48:39, Edit by BEEBE
  29. % Fix definition of NOTE, make it default in BOJ macro to try to reduce
  30. % incidence of VM errors
  31. % ----------------------------------------------------------------------
  32. % DVIALW PostScript macro definitions (keep in alphabetical order).  For
  33. % readability, these  are  heavily  commented,  but  we  adhere  to  the
  34. % convention that  percent is  used  ONLY to  mark  the beginning  of  a
  35. % comment (NEVER  occurs  inside a  PostScript  string), and  lines  are
  36. % limited to 80 characters.  That way, DVIALW can read these definitions
  37. % from a  file and  discard  comments and  trailing white  space  before
  38. % transmission to  the  PostScript output  file.   In the  interests  of
  39. % compactness, macros which  receive any significant  degree of use  are
  40. % given single letter names -- PostScript is already much too verbose.
  41. %
  42. % Coordinates are assumed to  be in pixels  (Resolution per inch).   The
  43. % page origin follows the  PostScript convention of  being in the  lower
  44. % left corner, y positive upwards along  the longer side of the page,  x
  45. % positive  to  the  right.   Letter  and  legal  sizes  are   therefore
  46. % equivalent as far as PostScript is concerned, but y coordinates can be
  47. % bigger in legal size.  In landscape mode, the page is rotated to place
  48. % the origin in  the upper left  corner, x positive  downward along  the
  49. % longer side of  the page, y  positive to the  right.  That way,  pages
  50. % eject from  the printer  upright when  viewed from  the front  of  the
  51. % printer.
  52. %
  53. % Document format is something like this:
  54. %
  55. %    %!PS-Adobe-1.0
  56. %    %%Dimensions: 0 0 612 792
  57. %    %%Title: DVIALW  -o1 -s300 foo12
  58. %    %%CreationDate: Sat Mar  8 10:52:52 1986
  59. %    %%Creator: BEEBE and [TeX82 DVI Translator Version 2.03b...]
  60. %    %%Pages: (atend)
  61. %    %%BugHistory: Incorporates save/restore and font reloading...
  62. %    %%BugHistory: Incorporates Allan Hetzel's 31-Oct-85 DARPA...
  63. %    %%EndComments
  64. %    %%EndProlog
  65. %    %%Page: 0 1
  66. %    TeXdict begin
  67. %    BOJ
  68. %    BOP
  69. %    ...
  70. %     1 EOP
  71. %    ^LBOP
  72. %    ...
  73. %     1 EOP
  74. %    ^LBOP
  75. %    ...
  76. %     1 EOP
  77. %    ^LEOJ
  78. %    %%Trailer
  79. %    %%Pages: 7
  80. %    %%PageTable:  0 1 3434
  81. %    ^D
  82. %
  83. % One formfeed is output  for each printed page  copy, in order to  make
  84. % spooler page accounting simple.  The additional comments wrapping  the
  85. % BOJ ..  EOJ  sequence conform  to  Adobe PostScript  file  structuring
  86. % conventions, and the first line can be used by the spooler to identify
  87. % the file as containing PostScript.
  88. % ----------------------------------------------------------------------
  89.  
  90.  
  91. /TeXdict 200 dict def        % dictionary for these definitions
  92. TeXdict begin
  93.  
  94. % bdf -- bind def (for efficiency)
  95. % Usage -- just like def, but not on constant objects
  96. /bdf {bind def} def
  97.  
  98. % B -- draw bar (TeX rule) of size w by h at currentpoint
  99. % Usage -- w h B
  100. /B
  101. {
  102.   /h exch def
  103.   /w exch def
  104.   gsave
  105.   currentpoint
  106.   newpath
  107.     moveto
  108.     w 1 sub 0 rlineto
  109.     0 h 1 sub rlineto
  110.     w 1 sub neg 0 rlineto
  111.   closepath fill
  112.   grestore
  113. } bdf
  114.  
  115. % BOJ -- beginning of job (EOF ends it and closes TeXdict)
  116. % Usage -- BOJ
  117. /BOJ
  118. {
  119.   72 Resolution div 72 Resolution div scale
  120.   userdict /note known 
  121.   {NOTE}                % default page format for ALW
  122.   {LETTER}                % default page format for others
  123.   ifelse
  124. } bdf
  125.  
  126. % BOP -- beginning of page
  127. % Usage -- BOP
  128. /BOP
  129. {
  130.   clear
  131.   Mtrx setmatrix
  132.   25 0 translate % Physical page origin is at (-25,0) from the top left corner
  133. } bdf
  134.  
  135. % ch-fieldname -- extract field from ch-data array (order defined by positions
  136. % in first array argument to macro D)
  137. % Usage -- ch-fieldname
  138. /ch-image  {ch-data 0 get} bdf    % the bitmap hex string image
  139. /ch-xoff   {ch-data 1 get} bdf    % pixels from left edge of bitmap to char origin
  140. /ch-yoff   {ch-data 2 get} bdf    % pixels from top edge of bitmap to char origin
  141. /ch-width  {ch-data 3 get} bdf    % bitmap width in pixels
  142. /ch-height {ch-data 4 get} bdf  % bitmap height in pixels
  143. /ch-tfmw   {ch-data 5 get} bdf    % pixels to next character (precise flt value)
  144.  
  145. % CharBuilder -- image one character
  146. % Usage -- fontdict ch CharBuilder
  147. /CharBuilder
  148. {
  149.   /ch-code exch def        % save the char code
  150.   /font-dict exch def        % and the font dict.
  151.   /ch-data font-dict /BitMaps get
  152.     ch-code get def        % get the bitmap descriptor for char
  153.   ch-data null eq not        % show character if entry is not empty
  154.   {
  155.     ch-tfmw                0
  156.     ch-xoff neg            ch-yoff ch-height sub
  157.     ch-width ch-xoff sub    ch-yoff
  158.     setcachedevice
  159.     0 0 SNAP translate
  160.     ch-width ch-height true [ 1 0 0 -1 ch-xoff ch-yoff ]
  161.     {ch-image} imagemask
  162.   } if
  163. } bdf
  164.  
  165.  
  166. % D -- define new character in current font
  167. % Usage -- [<bitmap> xoff yoff pixwid pixht tfmpixwid] charnum D
  168. /D
  169. {
  170.   /ch-code exch def
  171.   /ch-data exch def
  172.   currentfont /BitMaps get ch-code ch-data put
  173.   currentfont /Encoding get ch-code dup 3 string cvs cvn put
  174. } bdf
  175.  
  176. % EOJ -- end of job
  177. % Usage -- EOJ
  178. /EOJ
  179. {
  180.   end                % matches begin issued before BOJ
  181. } bdf
  182.  
  183. % EOP -- end of page
  184. % Usage -- ncopies EOP
  185. /EOP
  186. {
  187. /#copies exch def
  188. showpage
  189. } bdf
  190.  
  191. % LANDSCAPE -- landscape format page (11inH x 8.5inV)
  192. % Usage -- LANDSCAPE
  193. /LANDSCAPE
  194. {
  195.   letter initmatrix
  196.   72 Resolution div dup scale
  197.   0 3300 translate
  198.   -90 rotate
  199.   0 -750 translate
  200.   Mtrx currentmatrix pop
  201. } bdf
  202.  
  203. % LEGAL -- legal format page (8.5inH x 13inV)
  204. % Usage -- LEGAL
  205. /LEGAL
  206. {
  207.   legal initmatrix
  208.   72 Resolution div dup scale
  209.   0 900 translate
  210.   Mtrx currentmatrix pop
  211. } bdf
  212.  
  213. % LETTER -- letter format page
  214. % Usage -- LETTER
  215. /LETTER
  216. {
  217.   letter initmatrix
  218.   72 Resolution div dup scale
  219.   Mtrx currentmatrix pop
  220. } bdf
  221.  
  222. % M -- moveto
  223. % Usage -- x y M
  224. /M
  225. {
  226.   moveto
  227. } bdf
  228.  
  229. % Mtrx -- permanent storage for page transformation matrix
  230. % Usage -- Mtrx
  231. /Mtrx 6 array def
  232.  
  233. % NF -- define new font
  234. % Usage -- /fontname NF
  235. /NF
  236. {
  237.   /newname exch def
  238.   newname 7 dict def
  239.   newname load
  240.   begin
  241.     /BitMaps 128 array def
  242.     /BuildChar { CharBuilder } def
  243.     /Encoding 128 array def
  244.     0 1 127 { Encoding exch /.notdef put } for
  245.     /FontBBox [ 0 0 1 1 ] def
  246.     /FontMatrix [ 1 0 0 1 0 0 ] def
  247.     /FontType 3 def
  248.   end
  249.   newname newname load definefont pop
  250. } bdf() pop
  251.  
  252. % NOTE -- note format page (increases available virtual memory from 240K
  253. %      to 340K on Apple LaserWriter)
  254. % Usage -- NOTE
  255. /NOTE
  256. {
  257.   note initmatrix
  258.   72 Resolution div dup scale           % set scaling to 1.
  259.   Mtrx currentmatrix pop
  260. } bdf
  261.  
  262. % P -- show string at current point, updating horizontal position to new endpt
  263. % Usage -- (string) P
  264. /P {show} bdf() pop
  265.  
  266. % Q -- draw bar of last size set by B command at specified point
  267. % Usage -- x y Q
  268. /Q {moveto w h B} bdf() pop
  269.  
  270. % R -- move relative right and show string, updating horizontal position to
  271. %      new endpoint
  272. % Usage -- (string) xxx R
  273. /R {0 rmoveto show} bdf() pop
  274.  
  275. % Resolution -- device resolution in dots/inch
  276. % Usage -- Resolution
  277. /Resolution 300 def
  278.  
  279. % S -- move absolute and show string, updating horizontal position to new endpt
  280. % Usage -- (string) xxx yyy S
  281. /S {moveto show} bdf() pop
  282.  
  283. % SF -- set new font at scale nnn (nnn = 1 normally; 2 gives double size chars)
  284. % Usage -- nnn /fontname SF
  285. /SF {findfont exch scalefont setfont} bdf() pop
  286.  
  287. % SNAP -- convert coordinates to integer device coordinates and back again
  288. % Usage -- xxx yyy SNAP (leave xxx' yyy' on stack)
  289. /SNAP {transform 2 {floor 0.5 add exch} repeat itransform} bdf
  290.  
  291. % T -- move absolute horizontally and show string, updating horizontal position
  292. % to new endpt
  293. % Usage -- (string) xxx T
  294. /T {currentpoint exch pop moveto show} bdf() pop
  295.  
  296. end                % TeXdict
  297.